export default {
	props: {
		config: {
			type: Object
		},
		complex: {
			type: Object
		},
		zoom: {
			type: Number,
			required: false
		}
	},
	watch: {
		config: {
			deep: true,
			immediate: true, // 页面初始化后就执行
			handler(val) {
				if (val.hasOwnProperty("attr")) {
					this._initAttr()
				}
				if (val.hasOwnProperty("data")) {
					this[val.data.key] = val.data.value
				}
			},
		},
	},
	computed: {
		active() {
			return this.config.active
		}
	},
	created() {
		// 请求数据
		this._initAttr()
	},
	methods: {
		// 修改属性值
		_initAttr() {
			try {
				let data = {}
				this.config.attr.forEach(item => {
					data[item.key] = item.data;
				})
				this.attr = data;
			} catch (e) {
				//TODO handle the exception
				console.log('修改属性值错误：', e)
			}
		},
	}
}
